package com.cn.wanxi.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DataEncoding {
    public static String CastEncoding(String param)  throws IOException {
        param = new String(param.getBytes("ISO-8859-1"), "utf-8");
        return param;
    }
    public static void setCharacterEncoding(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
    }
    public static void setTextContentType(HttpServletResponse resp){
        resp.setContentType("text/html;charset=utf-8");
    }
    public static void setJsonContentType(HttpServletResponse resp){
        resp.setContentType("application/json");
    }
}
